
// 地址-方式-请求体-请求头
export default function(url,method='GET',data={},header={'Content-type':'application/json'}){
  // 数据加载
  wx.showLoading({
    title: '加载中',
  });
  return new Promise((resolve,reject)=>{
    wx.request({
      url,
      data,
      header,
      method,
      success: (result) => {
        resolve(result.data);
        wx.hideLoading();
      },
      fail:(err)=>{
        reject(err);
        wx.hideLoading();
        wx.showLoading({
          title:'加载出错！',
          complete(){
            setTimeout(function () {
              wx.hideLoading()
            }, 1000)
          }
        })
      }
    });
  })
}